import java.util.Collections;
import java.util.Hashtable;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-02
 * Time: 15:47
 */
public class Demo3 {
    public static void main(String[] args) throws InterruptedException {
        CopyOnWriteArrayList<String> copyOnWriteArrayList = new CopyOnWriteArrayList<>();
        Thread t1 = new Thread(() -> {
            copyOnWriteArrayList.add("abcde");
            copyOnWriteArrayList.add("bcedf");
            copyOnWriteArrayList.add("cdefg");
            copyOnWriteArrayList.add("hijk");
        });

        Thread t2 = new Thread(() -> {
            System.out.println(copyOnWriteArrayList.get(0));
        });

        t1.start();
        t2.start();
        t1.join();
        t2.join();

        Hashtable<String,Integer> hash = new Hashtable<>();
    }
}
